/***************************************************************************** 
** include/configs/imap_dev.h 
** 
** Copyright (c) 2009~2014 ShangHai Infotm Ltd all rights reserved. 
** 
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
** 
** Description: iMAPx200 develop board configuration.
**
** Author:
**     warits	<warits.wang@infotmic.com.cn>
**      
** Revision History: 
** ----------------- 
** 1.1  05/31/2010 
*****************************************************************************/

#ifndef __IMAPCFG_DEV_H__
#define __IMAPCFG_DEV_H__
#define CONFIG_BOARD_LINGHUA
/*
 * High Level Configuration Options
 * (easy to change)
 */
//#define CONFIG_SYS_DISK_iNAND
//#define CONFIG_SYS_SDRAM 256
#define CONFIG_SYS_SDRAM 512
#define CONFIG_NDISK_FTL

//#define CONFIG_TEST_VERSION
#define SOURCE_CHANNEL 1     //if not defined, it will defaultly 0.

#ifdef CONFIG_SYS_DISK_iNAND
#define iNAND_CHANNEL  2
#define CONFIG_HIBERNATE      //Hiberat location capacity value. If define this macro, Hiberat location will be enabled automaticlly, 
#endif

/* This option enable android recovery */
//#define CONFIG_RESET_CHECK
//#define CONFIG_DISPLAY_VERSION
//#define CONFIG_ANDROID_RECOVERY
//#define CONFIG_BOOT_AUTO_ADJUST
/* Android recovery needs the following gpio keys */
#if 0
#define CONFIG_MENU_KEY_GPIO GPODAT
#define CONFIG_MENU_KEY_GPIO_NUM 11
#endif

#if 0
/* (home) */
#define CONFIG_RECOVERY_KEY1_GPIO GPADAT
#define CONFIG_RECOVERY_KEY1_GPIO_NUM 7

/* (back) */
#define CONFIG_RECOVERY_KEY2_GPIO GPEDAT
#define CONFIG_RECOVERY_KEY2_GPIO_NUM 14
#define CONFIG_RECOVERY_KEY2_GPIO_NAME "SCREEN"
#endif

#if 0
#define CONFIG_MINUS_KEY_GPIO GPADAT
#define CONFIG_MINUS_KEY_GPIO_NUM 5
#define CONFIG_PLUS_KEY_GPIO GPEDAT
#define CONFIG_PLUS_KEY_GPIO_NUM 14
#endif
#define CONFIG_RECOVERY_KEY1_GPIO GPEDAT
#define CONFIG_RECOVERY_KEY1_GPIO_NUM 14

#define CONFIG_MOTOR_GPIO		GPEDAT
#define CONFIG_MOTOR_GPIO_PUD
#define CONFIG_MOTOR_GPIO_NUM	10
#define CONFIG_MOTOR_GPIO_LOW

/* This option enable wince features, such as bootup, and bootw */
//#define CONFIG_WINCE_FEATURE	

/* Boot image */
//#define CONFIG_WINCE_COMMON
#define CONFIG_LINUX_COMMON
#define CONFIG_LOGO_GZIP
#define CONFIG_LOGO_GZIP_W		800
#define CONFIG_LOGO_GZIP_H		480
#define CONFIG_GZIP_LOGO_FILE	<leader_logo.h>

#define CONFIG_BATT_GZIP_W		300
#define CONFIG_BATT_GZIP_H		300
#define CONFIG_GZIP_BATT_FILE	<batt.enUS.bin.gz.h>

/* Memory configuration */
	//#define CONFIG_SYS_DENALI_FILE	"asm/arch/denali_data/denali_sam_2x128_270Mau_m77.h"
	//#define CONFIG_SYS_DENALI_FILE	"asm/arch/denali_data/denali_scs_2x256_270Mau_m77.h"
	//#define CONFIG_SYS_DENALI_FILE	"asm/arch/denali_data/denali_sam_4x128_270Mau.h"
	#define CONFIG_SYS_DENALI_FILE	"asm/arch/denali_data/denali_yifm722.h"
	//#define CONFIG_SYS_DENALI_FILE	"asm/arch/denali_data/denali_sam_4x128_270Mau_75half.h"
	//#define CONFIG_SYS_DENALI_FILE	"asm/arch/denali_data/denali_sam_4_128_270M_CL_5.h"

#define PHYS_SDRAM_1_SIZE		0x20000000		/* 256 MB in Bank #1 */
//#define CONFIG_DENALI_RFRATE	0x06420612
#define CONFIG_IMAPX200_INSP	0x46
#define CONFIG_DENALI_CS 	0x00000300

/* Board string */

/* Boot Env */
#define CONFIG_LINUX_DEFAULT_BOOTARGS "console=ttySAC3,115200 bootdelay=15 mem=512M"
#define CONFIG_LINUX_RECOVER_BOOTARGS "console=ttySAC3,115200 bootdelay=15"
#define CONFIG_EXTRA_ENV_SETTINGS "stdin=serial\0"  \
                                  "stdout=serial\0"  \
                                  "stderr=serial\0"  \
                                  "bootcmd=bootl x\0"  \

#define CONFIG_CLK_1056_266
//#define CONFIG_CLK_800_200
//#define CONFIG_CLK_800_266
//#define CONFIG_CLK_1008_252
/*
#define CONFIG_CLK_533_133_66
#define CONFIG_CLK_400_100_50
#define CONFIG_CLK_400_133_66
#define CONFIG_CLK_800_266
#define CONFIG_CLK_800_200
#define CONFIG_CLK_800_133
#define CONFIG_CLK_840_210
#define CONFIG_CLK_MANUAL_MODE
#define CONFIG_CLK_600_200
#define CONFIG_CLK_450_150
#define CONFIG_CLK_936_234
#define CONFIG_CLK_1008_252
#define CONFIG_SYNC_MODE
*/

/* Drivers */
/* UART */
#define CONFIG_SERIAL4          1	/* we use uart0(SERIAL1) on iMAPx200 FPGA	*/

/* keybd */
//#define CONFIG_KEYBOARD	1

/* Gmac */
#define CONFIG_DRIVER_GMAC		1	/* we have a gmac on imapx200 */
#define CONFIG_ETH_RESET_GPIO	GPPDAT
#define CONFIG_ETH_RESET_GPIO_NUM	8

/* MMC */
#define CONFIG_MMC			1
#define CONFIG_IMAP_MMC			1
#define CONFIG_GENERIC_MMC		1

/* LCD */
#define CONFIG_LCD
#define CONFIG_LCD_IMAPX200
#define IMAPFB_HFP		210		/* front porch */
#define IMAPFB_HSW		20		/* hsync width */
#define IMAPFB_HBP		46		/* back porch */
#define IMAPFB_VFP		22		/* front porch */
#define IMAPFB_VSW		10		/* vsync width */
#define IMAPFB_VBP		23		/* back porch */
#define IMAPFB_HRES		800	/* horizon pixel x resolition */
#define IMAPFB_VRES		480		/* line cnt y resolution */
#define CONFIG_LCD_PANEL_GPIO		GPNDAT		//VCC_LCD33
#define CONFIG_LCD_PANEL_GPIO_Bit	14
#define CONFIG_LCD_EXTRA_GPIO		GPADAT		//VGH VGL
#define CONFIG_LCD_EXTRA_GPIO_Bit	6
#define CONFIG_LCD_BL_GPIO			GPADAT
#define CONFIG_LCD_BL_GPIO_Bit		6
#define CONFIG_LCD_TOUT_PIN		1			
#define CONFIG_LCDCON5				0x24000308
#define CONFIG_DIV_CFG4_VAL			0x1515
#define CONFIG_LCDCON1_CLKVAL		1
//#define CONFIG_LCD_BL_DELAY 		320000	//add by guang
//#define CONFIG_LCD_BL_LOW
//#define CONFIG_LCD_ENBLCTRL

/* SPI */
#if 0
#define CONFIG_IMAPX200_SPI
#define CONFIG_LOW_BATTERY_VAL		525
#define CONFIG_LOGO_BATTERY_VAL		485

#define CONFIG_POWER_GPIO       GPBDAT
#define CONFIG_POWER_GPIO_NUM   0x2
#endif

/* USB */
//#define CONFIG_DISABLE_BOOT_OTG
#define CONFIG_OTG_GPIO 
#define CONFIG_OTG_EX_GPIO  GPADAT
#define CONFIG_OTG_EX_GPIO_NUM 7
/* NOR */
#define CONFIG_NOR
#define CONFIG_SYS_BOOT_NOR
#define CONFIG_SYS_NOR_RC 0xa

/* Init GPIO values */
#if 0
#define CONFIG_SYS_INIT_GPIO0 GPACON
#define CONFIG_SYS_INIT_GPIO0_VAL 0x10
#define CONFIG_SYS_INIT_GPIO1 GPADAT
#define CONFIG_SYS_INIT_GPIO1_VAL 0x4
#define CONFIG_SYS_INIT_GPIO2 GPOCON
#define CONFIG_SYS_INIT_GPIO2_VAL (1 << 26)
#define CONFIG_SYS_INIT_GPIO3 GPODAT
#define CONFIG_SYS_INIT_GPIO3_VAL (1 << 13)
#endif

/* More Init GPIOs */
//GPO13  5Vdev
//GPJ3   3.3vIO
/* GPIO, BIT, DIR(0:out, 1:in), VAL */
/*#define CONFIG_SYS_EX_INIT_GPIO {	\
	{GPODAT, 13, 0, 1, 0},	\
	{GPJDAT, 3, 0,  1, 0},  \
	{GPADAT, 0, 0,  1, 0},\
	{GPCDAT, 7, 0,  1, 0},\
	{GPODAT,14,0,1,0},\
	{0, 0, 0, 0, 0}	\
}*/
#if 0   //auto reboot failed
#define CONFIG_SYS_EX_INIT_GPIO {	\
	{GPODAT, 13, 0, 1, 0},	\
	{GPJDAT, 3, 0,  1, 0},  \
	{0, 0, 0, 0, 0}	\
}
#endif
#if 1   //auto reboot ok
#define CONFIG_SYS_EX_INIT_GPIO {	\
	{GPODAT, 13, 0, 1, 0},  \
	{0, 0, 0, 0, 0}	\
}
#endif
/* GPIO KEYS */

/* Disable settings */

#define CONFIG_SYS_NAND_8K_PAGE			//U0E
#undef CONFIG_SYS_NAND_2K_PAGE
#define CONFIG_SYS_NAND_MLC	/* 4bit ECC, 9bytes per 512 */
#undef CONFIG_SYS_NAND_SLC	/* 1bit ECC, 4bytes per 2048 */

/* Include the common config file */
#include <configs/imapx.h>
#define CONFIG_BOARD_MAGIC	0xdb6db610
#define CONFIG_BOARD_HWVER	0x00060104
#define CONFIG_BOARD_OEM	0xe

#endif
